package org.future.task.core.manager;

import org.future.task.core.handler.RunnableTask;

public class TaskFactory implements Runnable {

    private final RunnableTask runnableTask;

    private final int batchSize;

    public TaskFactory(RunnableTask runnableTask) {
        this(runnableTask, 500);
    }

    public TaskFactory(RunnableTask runnableTask, int batchSize) {
        this.runnableTask = runnableTask;
        this.batchSize = batchSize;
    }

    @Override
    public void run() {
        while (true) {
            try {
                runnableTask.runnable(batchSize);
            } catch (Exception e) {
                //TODO 异常捕获处理
                e.printStackTrace();
            }
        }
    }
}
